$(window).ready(function(){
	
	function afterSourceToDestiFunc(optionDatas){
		alert("待选移入已选,"+$.objToJSONString(optionDatas))
	}
	
	function afterDestiToSourceFunc(optionDatas){
		alert("已选移入待选,"+$.objToJSONString(optionDatas))
	}
	
	$("a[id^='aDiv']").click(function(){
		var num = $(this).attr("id").substr(4,2);
		$('#div'+num).attr('title',i18n.message.msg).dialog($.extend({},dialogConfig));
	});
	
	//1.常规
	$('#propertyName').multiSelector({"afterSourceToDestiFunc":afterSourceToDestiFunc,"afterDestiToSourceFunc":afterDestiToSourceFunc});

	var destiDatas = [{name:"a1",code:"aa1"},
				{name:"a2",code:"aa2"},
				{name:"a3",code:"aa3"},
				{name:"a4",code:"aa4"},
				{name:"a5",code:"aa5"},
				{name:"a6",code:"aa6"},
				{name:"a7",code:"aa7"},
				{name:"a8",code:"aa8"},
				{name:"a9",code:"aa9"},
				{name:"a10",code:"aa10"}];
				
	var sourceDatas = [{name:"b1",code:"bb1"},
				{name:"b2",code:"bb2"},
				{name:"b3",code:"bb3"},
				{name:"b4",code:"bb4"},
				{name:"b5",code:"bb5"},
				{name:"b6",code:"bb6"},
				{name:"b7",code:"bb7"},
				{name:"b8",code:"bb8"},
				{name:"b9",code:"bb9"},
				{name:"b10",code:"bb10"}];
	
	
	
	$('#btnSetSourceDatas').bind('click',function(){
		$('#propertyName').multiSelector("setSourceDatas",sourceDatas,{valueTextMap:{textKey:'name',valueKey:'code'}});
	});
	$('#btnSetDestiDatas').bind('click',function(){
		$('#propertyName').multiSelector("setDestiDatas",destiDatas,{valueTextMap:{textKey:'name',valueKey:'code'}});
	});
	
	$('#btnGetSourceSelectedValues').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getSourceSelectedValues")));
	});
	$('#btnGetDestiSelectedValues').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getDestiSelectedValues")));
	});
	
	$('#btnGetSourceAllValues').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getSourceAllValues")));
	});
	$('#btnGetDestiAllValues').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getDestiAllValues")));
	});
	
	$('#btnGetSourceSelectedDatas').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getSourceSelectedDatas")));
	});
	$('#btnGetDestiSelectedDatas').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getDestiSelectedDatas")));
	});
	
	$('#btnGetSourceAllDatas').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getSourceAllDatas")));
	});
	$('#btnGetDestiAllDatas').bind('click',function(){
		alert($.objToJSONString($('#propertyName').multiSelector("getDestiAllDatas")));
	});
	
	//2.带分隔符
	$('#propertyName2').multiSelector();
	$('#btnSetSourceDatas2').bind('click',function(){
		$('#propertyName2').multiSelector("setSourceDatas",sourceDatas,{valueTextMap:{textKey:'name - code',valueKey:'code'},textSeparator : " - "});
	});
	$('#btnSetDestiDatas2').bind('click',function(){
		$('#propertyName2').multiSelector("setDestiDatas",destiDatas,{valueTextMap:{textKey:'name # code',valueKey:'code'},textSeparator : " # "});
	});
	
});